﻿using System;
using System.Linq;
using System.Web;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace MvcWebApplication.Models
{
    public class WebDataEntity : DbContext
    {
        public DbSet<Nhanvien> Nhanviens { get; set; }
        public DbSet<Khachhang> Khachhangs { get; set; }
        public DbSet<Tintuc> Tintucs { get; set; }
        public DbSet<Nhacungcap> Nhacungcaps { get; set; }
        public DbSet<HangSX> HangSXs { get; set; }
        public DbSet<Thongtin> Thongtins { get; set; }
        public DbSet<Sanpham> Sanphams { get; set; }
        public DbSet<Ykien> Ykiens { get; set; }
        public DbSet<Hoadon> Hoadons { get; set; }
        public DbSet<Chitiethaodon> Chitiethaodons { get; set; }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }
    }
    public class Nhanvien
    {
        [Key]
        public int NhanvienID { get; set; }
        public string UserName { get; set; }
        public string Password { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }
    }
    public class Khachhang
    {
        [Key]
        public int KhachhangID { get; set; }
        public string UserName { get; set; }
        public string Password { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }
        public string Sodienthoai { get; set; }
        public string Diachi { get; set; }
        public virtual ICollection<Hoadon> Hoadons { get; set; }
    }
    public class Tintuc
    { 
        [Key]
        public int TintucID { get; set; }
        public int NhanvienID { get; set; }
        public string Tieude { get; set; }
        public string Noidung { get; set; }
        public DateTime Ngaydang { get; set; }
        public virtual Nhanvien Nhanvien { get; set; }
    }
    public class Nhacungcap
    {
        [Key]
        public int NhaccID { get; set; }
        public string NccName { get; set; }
        public string Diachi { get; set; }
        public string Dienthoai { get; set; }
        public string Email { get; set; }
        public virtual ICollection<Sanpham> Sanphams { get; set; }
    }
    public class HangSX
    {
        [Key]
        public int HangsxID { get; set; }
        public string HsxName { get; set; }
        public virtual ICollection<Sanpham> Sanphams { get; set; }
    }
    public class Sanpham
    {
        [Key]
        public int SanphamID { get; set; }
        public string SpName { get; set; }
        public double Dongia { get; set; }
        public string Anh { get; set; }
        public int NhaccID { get; set; }
        public virtual  Nhacungcap Nhacungcap { get; set; }
        public int HangsxID { get; set; }
        public virtual HangSX HangSX { get; set; }
        public int ThongtinID { get; set; }
        public virtual Thongtin Thongtin { get; set; }
        public virtual ICollection<Chitiethaodon> Chitiethoadons { get; set; }
    }
    public class Thongtin
    {
        [Key]
        public int ThongtinID { get; set; }
        public string CPU { get; set; }
        public string RAM { get; set; }
        public string HDD { get; set; }
        public string Cauhinhcitiet { get; set; }
        public string Thongtinkhac { get; set; }
    }
    public class Ykien
    {
        [Key]
        public int YkienID { get; set; }
        public int SanphamID { get; set; }
        public int KhachhangID { get; set; }
        public string Noidung { get; set; }
        public DateTime Ngaygui { get; set; }
        public virtual Sanpham Sanpham { get; set; }
        public virtual Khachhang Khachhang { get; set; }
    }
    public class Hoadon
    {
        [Key]
        public int HoadonID { get; set; }
        public int KhachhangID { get; set; }
        public DateTime Ngaylap { get; set; }
        public bool Trangthai { get; set; }
        public virtual Khachhang Khachhang { get; set; }
        public virtual ICollection<Chitiethaodon> Chitiethoadons { get; set; }
    }
    public class Chitiethaodon
    {
        [Key]
        public int HoadonID { get; set; }
        public virtual Hoadon Hoadon { get; set; }
        [Key]
        public int SanphamID { get; set; }
        public virtual Sanpham Sanpham { get; set; }
        public int Soluong { get; set; }
    }
}